package com.xinqi.modules.chat.chat.official.controller.web;

import com.xinqi.common.base.response.R;
import com.xinqi.common.satoken.utils.LoginHelper;
import com.xinqi.modules.chat.chat.official.dto.req.ChatAssistantConfigUpdateDTO;
import com.xinqi.modules.chat.chat.official.dto.rsp.ChatAssistantConfigResultDTO;
import com.xinqi.modules.chat.chat.official.dto.rsp.ChatAssistantTypeResultDTO;
import com.xinqi.modules.chat.chat.official.service.ChatAssistantConfigService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * WEB -- 新奇助手通知设置
 *
 * @author: yyzhen
 * @date: 2023/05/05
 */
@RestController
@RequestMapping("/web/assistant-config")
@RequiredArgsConstructor
public class ChatAssistantConfigWebController {
    private final ChatAssistantConfigService chatAssistantConfigService;


    /**
     * 新奇助手通知设置-详情
     */
    @Operation(summary = "新奇助手通知设置-详情")
    @GetMapping("/info")
    public R<ChatAssistantConfigResultDTO> info() {
        return R.data(chatAssistantConfigService.infoConfig(LoginHelper.getUserId()));
    }

    /**
     * 新奇助手通知设置-修改
     */
    @Operation(summary = "新奇助手通知设置-修改")
    @PostMapping("edit")
    public R<ChatAssistantConfigResultDTO> edit(@Validated @RequestBody ChatAssistantConfigUpdateDTO dto) {
        dto.setOperationUserId(LoginHelper.getUserId());
        return R.data(chatAssistantConfigService.editConfig(dto));
    }

    /**
     * 新奇助手通知设置-修改
     */
    @Operation(summary = "新奇助手-消息类型")
    @GetMapping("type/list")
    public R<List<ChatAssistantTypeResultDTO>> typeList() {
        return R.data(chatAssistantConfigService.typeList());
    }

}
